module Maze
  module PngFormatter
    module DrawingHelpers
      PADDING = 10
      LENGTH  = 30

      def draw(output_file = nil)
        lines.each do |end_points|
          image.line(*end_points, ChunkyPNG::Color::BLACK)
        end
        image.save(output_file, :fast_rgb) if output_file
      end

      private

      def background_colour
        ChunkyPNG::Color::WHITE
      end

      def padding_offset
        PADDING * 2
      end

      def draw_image
        maze.height.times do |row|
          maze.width.times do |column|
            closed_line_segments(row, column).each do |line_segment|
              lines << line_segment.map { |point| point.raw }.flatten
            end
          end
        end
      end
    end
  end
end
